import Dicom.DcmSnd;

import java.io.File;

public class MainClient {
    public static void main(String[] args) {
        File current=new File(MainConfig.File);
        DcmSnd dcmSnd = new DcmSnd(MainConfig.Hostpital);
        dcmSnd.setCalledAET(MainConfig.AeTitle);
        dcmSnd.setRemoteHost(MainConfig.Host);
        dcmSnd.setRemotePort(MainConfig.Port);
        dcmSnd.setOfferDefaultTransferSyntaxInSeparatePresentationContext(false);
        dcmSnd.setSendFileRef(false);
        dcmSnd.setStorageCommitment(false);
        dcmSnd.setPackPDV(true);
        dcmSnd.setTcpNoDelay(true);
        dcmSnd.addFile(current);
        dcmSnd.configureTransferCapability();
        while (dcmSnd.getLastSentFile() < dcmSnd.getNumberOfFilesToSend()) {
            try {
                dcmSnd.start();
                dcmSnd.open();
                dcmSnd.send();
                if (dcmSnd.isStorageCommitment()) {
                    if (dcmSnd.commit()) {
                        dcmSnd.waitForStgCmtResult();
                    }
                }
                dcmSnd.close();
            }
            catch (Exception err) {
                System.err.println(err);
            }
            finally {
                dcmSnd.stop();
            }
        }
    }
}
